# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/dsa/dsa.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Ethernet Switch Device Tree Bindings

maintainers:
  - Andrew Lunn <andrew@lunn.ch>
  - Florian Fainelli <f.fainelli@gmail.com>
  - Vivien Didelot <vivien.didelot@gmail.com>

description:
  This binding represents Ethernet Switches which have a dedicated CPU
  port. That port is usually connected to an Ethernet Controller of the
  SoC. Such setups are typical for embedded devices.

select: false

properties:
  $nodename:
    pattern: "^switch(@.*)?$"

  dsa,member:
    minItems: 2
    maxItems: 2
    description:
      A two element list indicates which DSA cluster, and position within the
      cluster a switch takes. <0 0> is cluster 0, switch 0. <0 1> is cluster 0,
      switch 1. <1 0> is cluster 1, switch 0. A switch not part of any cluster
      (single device hanging off a CPU port) must not specify this property
    $ref: /schemas/types.yaml#/definitions/uint32-array

patternProperties:
  "^(ethernet-)?ports$":
    type: object
    properties:
      '#address-cells':
        const: 1
      '#size-cells':
        const: 0

    patternProperties:
      "^(ethernet-)?port@[0-9]+$":
        type: object
        description: Ethernet switch ports

        properties:
          reg:
            description: Port number

          label:
            description:
              Describes the label associated with this port, which will become
              the netdev name
            $ref: /schemas/types.yaml#definitions/string

          link:
            description:
              Should be a list of phandles to other switch's DSA port. This
              port is used as the outgoing port towards the phandle ports. The
              full routing information must be given, not just the one hop
              routes to neighbouring switches
            $ref: /schemas/types.yaml#definitions/phandle-array

          ethernet:
            description:
              Should be a phandle to a valid Ethernet device node.  This host
              device is what the switch port is connected to
            $ref: /schemas/types.yaml#definitions/phandle

          phy-handle: true

          phy-mode: true

          fixed-link: true

          mac-address: true

        required:
          - reg

        additionalProperties: false

oneOf:
  - required:
      - ports
  - required:
      - ethernet-ports

additionalProperties: true

...
